/**
 * 
 */
package com.jie.eclipse.pan.listener;

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Scrollable;

import com.jie.eclipse.pan.data.BaseDataEntity;
import com.jie.eclipse.pan.editors.form.PllDetailPage;
import com.jie.eclipse.pan.utils.handle.FileHandle;

/**
 * @author yanjie
 *
 */
public class PModifyListener implements ModifyListener{
	public static final String TAG_PLLEDIT_LISTENER = "PLLEDIT_LISTENER";//保存xml
	private String type = "";
	private FileHandle fileHandle = null;
	
	protected BaseDataEntity data = null;
	/**
	 * 
	 */
	public PModifyListener(BaseDataEntity data) {
		this.data = data;
	}
	
	/**
	 * 
	 */
	public PModifyListener(String type, FileHandle fileHandle) {
		this.type = type;
		this.fileHandle = fileHandle;
	}
	
	public void modifyText(ModifyEvent paramModifyEvent) {
		if(TAG_PLLEDIT_LISTENER.equalsIgnoreCase(type) || "commonChange".equalsIgnoreCase(type)){
			Scrollable source = (Scrollable)paramModifyEvent.getSource();
			if(source.isFocusControl()){
				source.setData("change", true);
			}
		}
	}
	
	public static PModifyListener getPModifyListener(PllDetailPage detailPage){
		return new PModifyListener(PModifyListener.TAG_PLLEDIT_LISTENER,detailPage.getFileHandle());
	}
	
	public Object gpov(String paramName){
		if(this.data == null)return null;
		return this.data.gpov(paramName);
	}
}
